<!DOCTYPE html>
<html lang="zh">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <link href="../css/style.css" rel="stylesheet">
</head>
<style>
    button {
        width: 200px;
    }

    button:hover {
        background-color: skyblue;
    }

    .active {
        background-color: skyblue;
    }
</style>

<body>
    <div id="myApp">
        <p>您最喜欢的游戏是：{{mygame}}</p>
        <button v-on:click="btnClick('我的世界',1)" v-bind:class="{active:isActive == 1}">我的世界</button>
        <button v-on:click="btnClick('勇者斗恶龙',2)" v-bind:class="{active:isActive == 2}">勇者斗恶龙</button>
        <button v-on:click="btnClick('塞尔达传说',3)" v-bind:class="{active:isActive == 3}">塞尔达传说</button>
        <button @click="btnClick('魔界战记5',4)" v-bind:class="{active:isActive == 4}">魔界战记5</button>
    </div>
    <script>
        var myApp = new Vue({
            el: '#myApp',
            data: {
                mygame: '超级马里奥',
                isActive: 0,
            },
            methods: {
                btnClick: function (pname, i) {
                    console.log(123,this);
                    this.mygame = pname;
                    this.isActive = i;
                },
            },
            created:function(){
                console.log('创造');
            }
        });
    </script>
</body>

</html>